﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq.Expressions;
using Newtonsoft.Json.Linq;

using CanDoo;
using CanDoo.Core;
using CanDoo.Data;
using CanDoo.Web;
using CanDoo.FineUI;
using CanDoo.Extensions;
using CanDoo.Oil.Core.Models;
using CanDoo.Oil.Core.Contracts;
using CanDoo.Admin.Core.Contracts;
using FineUIPro;

namespace CanDoo.Oil.WebApp.financeBuyStatementDetail
{
    public partial class Edit : EditPagebase<IBuyStatementDetailContract, BuyStatementDetail>
    {
        public IBuyStatementContract BuyStatementContract { get; set; }
        public IBuyBillContract BuyBillContract { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (PageMode != pagemode.Add)
                    LoadData();
            }
        }

        protected override void LoadData(BuyStatementDetail entity)
        {
            ed_Name.SetValue(entity.Name);
            ed_BeforeMoney.SetValue(entity.BeforeMoney);
            ed_Money.SetValue(entity.Money);
            ed_LastedMoney.SetValue(entity.LastedMoney);
            ed_Remark.SetValue(entity.Remark);
        }

        protected override OperationResult SaveData(BuyStatementDetail entity)
        {
            entity.Name = ed_Name.GetValue().ToString();
            entity.BeforeMoney = ed_BeforeMoney.GetValue().ToDouble();
            entity.Money = ed_Money.GetValue().ToDouble();
            entity.LastedMoney = ed_LastedMoney.GetValue().ToDouble();
            entity.Remark = ed_Remark.GetValue().ToString();
            return base.SaveData(entity);
            
        }
    }
}
